/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package DataLayer;
import Entities.*;
import java.util.*;

/**
 *
 * @author itabas
 */
public class DataRepository {
    
    public Product GetProducById(String productId)
    {
        try
        {
            DataAccess dataAccess=new DataAccess();
            return dataAccess.getProductById(productId);
        }
        catch(Exception e)
        {
            return null;
        }
    }
    
    public boolean UpdateProduct(int productId, int currentUser, int currentPrice)
    {
        try
        {
            DataAccess dataAccess=new DataAccess();
            return dataAccess.updateProduct(productId, currentUser, currentPrice);
        }
        catch(Exception e)
        {
            return false;
        }
    }
    
    public boolean createNewProduct(String name, String description, String dayOfAuction,
                  int currentPrice, int minStep  ){
        try
        {
             DataAccess dataAccess=new DataAccess();
             return dataAccess.createNewProduct(name, description, dayOfAuction, currentPrice, minStep);
        }
        catch (Exception e)
        {
            return false;
        }
    }
    
    public boolean closeAuction(int productId)
    {
        try
        {
            DataAccess dataAccess=new DataAccess();
            return dataAccess.closeAuction(productId);
        }
        catch(Exception e)
        {
            return false;
        }
    }
    
    public List<Product> allProducts()
    {
        try{
            DataAccess dataAccess=new DataAccess();
            return dataAccess.allProducts();
        }
        catch(Exception e){
            return null;
        }
    }
    
    public User getUserByLogin(String login)
    {
        try
        {
            DataAccess dataAccess=new DataAccess();
            return dataAccess.getUserByLogin(login);
        }
        catch(Exception e)
        {
            return null;
        }
    }
}
